/***********************************************************************************
**  
* @copyright (c) 2010-2019, ChengDu Duyer Technology Co., LTD. All Right Reserved.
*
************************************************************************************/
/**
* @file	    mjs_mysql_result.h
* @version     
* @brief      
* @author   duye
* @date	    2016-12-27
* @note 
*
* 1. 2016-12-27 duye Created this file
*/

#pragma once

#include <string>
#include <list>
#include <map>
#include <duye_type.h>

class MJSMysqlRow {
public:
	// <titile, value>
	typedef std::map<std::string, std::string> MJSRowDataMap;

public:
	MJSMysqlRow();
	~MJSMysqlRow();

	void addPara(const std::string& title, const std::string& value);
	std::string getValue(const std::string& title);
	const MJSRowDataMap& getRowDataMap() const;

private:
	MJSRowDataMap m_row_data_map;
};

typedef std::list<MJSMysqlRow> MJSResultTable;

class MJSMysqlResult {
public:
	MJSMysqlResult();
	~MJSMysqlResult();

	uint32 row();
	uint32 row() const;

	void setAffected(const uint32& row);
	uint32 affected();
	uint32 affected() const;

	bool empty();
	bool empty() const;

	void insertRow(const MJSMysqlRow& row);
	const MJSResultTable& getTable() const;

private:
	uint32 m_affected;
	MJSResultTable m_table;
};